package com.bacel.nb.product.web.template.ViewModel;


import com.alibaba.fastjson.JSON;
import com.bacel.nb.product.web.util.WebUtilify;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;

/**
 * http://www.cnblogs.com/beiyeren/p/3873683.html
 */
public class FreeMarkerView extends ModelAndView {

    public FreeMarkerView(String module, String title) {
        this.setViewName("body");
        this.addObject("type", module);
        this.addObject("title", title);

        //this.addObject("userinfo", JSON.toJSONString(WebUtilify.loginuser));
//        Object pObj = session.getAttribute("Userinfo");
//        if (pObj != null) {
//            this.addObject("userinfo", JSON.toJSONString(pObj));
//        }
    }

    public FreeMarkerView(String module, String title, String nowpath, String verifypath, HttpSession session) {
        this.setViewName("body");
        this.addObject("type", module);
        this.addObject("title", title);
        this.addObject("nowpath", nowpath);
        this.addObject("verifypath", verifypath);
        Object pObj = session.getAttribute(WebUtilify.LoginUserKey);
        if (pObj != null) {
            this.addObject("userinfo", JSON.toJSONString(pObj));
        }
        //this.addObject("userinfo", JSON.toJSONString(WebUtilify.loginuser));
    }
}
